//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Example #10—Arithmetic
// CS 151, 6 Apr 2009
// ECC, Spring 2009
// Niko Culevski
// Program to show values of primitive types
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

public class Arithmetic
{   
    //member variables--class level variables
	static float f;
	static double d = -10.0/0;	//no error!
	public static void main(String[] args)
	{
       //local variables
	   int m = 25, n = 7;
	   System.out.println("m = " + (++m));
	   System.out.println("n = " + (n--));

	   //access member variables from within a static method
	   //requires static declaration of the variables
	   System.out.println("f = " + f);
	   System.out.println("d = " + d);
	   int sum = m + n;
	   System.out.println("m + n = " + sum);
	   int difference = m - n;
	   System.out.println("m - n = " + difference);
	   int product = m * n;
	   System.out.println("m * n = " + product);
	   int quotient = m / n;
	   System.out.println("m / n = " + quotient);
	   int remainder = m % n;
	   System.out.println("m % n = " + remainder);
	   System.out.println(12345*234567/234567);
	   System.out.println(12345/234567*234567);
	   System.out.println(7.6 % 2.9);
	   System.out.println(-5 % 2);
	   //m = 26, n = 6
	   System.out.println(m >> 2);
	   System.out.println(n << 3);
	   System.out.println(-1 >>> 2);
	   System.out.println(Double.NaN == Math.sqrt(-1));
	   System.out.println(Double.NaN != Double.NaN);
	   System.out.println("4 | 3 = " + (4 | 3));	// 4 = 0100, 3 = 0011
	   System.out.println("4 & 3 = " + (4 & 3));
	   System.out.println("~4 = " + ~4);
       //-5 = 11111111111111111111111111111011
    }
}
